You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Title: add SIR epidemic model with Mesa 4.0 discrete space API`
Summary
Adds a new SIR (Susceptible-Infected-Recovered) epidemic model demonstrating disease spread on a 2D grid using Mesa 4.0's discrete space API.
Files
model.py: SIR model using OrthogonalMooreGrid and CellAgent
app.py: SolaraViz visualization with adjustable parameters
Readme.md: Background, model description, parameters, how to run, results
metadata.toml: Structured metadata for discoverability
What this demonstrates
CellAgent for grid-based agents with state transitions
OrthogonalMooreGrid with Moore neighborhood for spatial interaction
DataCollector for tracking population-level metrics
SolaraViz interactive visualization
GSoC contributor checklist
Context & motivation: I built this model as part of my GSoC preparation for the Behavioral Modeling Framework project. The SIR model is a natural fit for mesa-examples because it demonstrates state-based agent behavior — agents transition between states based on local interactions, which is a pattern common to many behavioral models.
What I learned: Building this model taught me Mesa 4.0's discrete space system — how CellAgent replaces the old mesa.Agent + manual grid placement pattern, how cell.neighborhood replaces get_neighborhood(), and how agent movement works through cell assignment rather than move_agent(). The biggest difference from Mesa 3.x is that agents "live in" cells rather than being "placed on" a grid.
infection_timer increments for all agents regardless of state, so susceptible agents will recover almost instantly upon infection.
SIRModel.__init__ is missing the seed parameter that app.py passes, which will throw a TypeError at runtime.
One design issue: Infection spreads to the entire Moore neighborhood rather than just cellmates, making movement largely irrelevant to transmission dynamics.
Thanks for the review Vanya!
On bug 2 — good catch, fixed. Removed the seed parameter from app.py since model.py doesn't accept it. Pushed the fix.
On bug 1 — the infection_timer += 1 is inside the if self.state == "Infected" block (line 44-46), so it only increments for infected agents. Susceptible agents won't hit that code path.
On the design point about Moore neighborhood vs cellmates — I used the full neighborhood intentionally so the epidemic spreads at a visible rate with 100 agents on a 20x20 grid. With only cellmate transmission, the probability of two agents sharing a cell is low and the epidemic stalls. Happy to add a transmission_radius parameter if you think that would be a useful improvement.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title: add SIR epidemic model with Mesa 4.0 discrete space API`
Summary
Adds a new SIR (Susceptible-Infected-Recovered) epidemic model demonstrating disease spread on a 2D grid using Mesa 4.0's discrete space API.
Files
model.py: SIR model usingOrthogonalMooreGridandCellAgentapp.py: SolaraViz visualization with adjustable parametersReadme.md: Background, model description, parameters, how to run, resultsmetadata.toml: Structured metadata for discoverabilityWhat this demonstrates
CellAgentfor grid-based agents with state transitionsOrthogonalMooreGridwith Moore neighborhood for spatial interactionDataCollectorfor tracking population-level metricsGSoC contributor checklist
Context & motivation: I built this model as part of my GSoC preparation for the Behavioral Modeling Framework project. The SIR model is a natural fit for mesa-examples because it demonstrates state-based agent behavior — agents transition between states based on local interactions, which is a pattern common to many behavioral models.
What I learned: Building this model taught me Mesa 4.0's discrete space system — how
CellAgentreplaces the oldmesa.Agent+ manual grid placement pattern, howcell.neighborhoodreplacesget_neighborhood(), and how agent movement works through cell assignment rather thanmove_agent(). The biggest difference from Mesa 3.x is that agents "live in" cells rather than being "placed on" a grid.Learning repo: https://github.com/B2prakash/GSoC-learning-space
Readiness checks:
python model.py